#include "Clouds.h"


Clouds::Clouds(Monster* m)
{
	monster = m;

	/**
	PARTICLE TEST
	**/
	// Load image and initialize sprite
	std::shared_ptr<sf::Texture> texture(new sf::Texture());
	if (!texture->loadFromFile("particle.png"));
		

	// Create emitter
	emitter = thor::UniversalEmitter::create();
	emitter->setEmissionRate(200.f*monster->getHealthDecimal());
	emitter->setParticleLifetime(sf::seconds(2.f));
	//emitter->setParticlePosition(MousePosition(window));

	// Create particle system
	system = new thor::ParticleSystem(texture);
	//system = thor::ParticleSystem(texture);
	system->addEmitter(emitter);

	thor::ColorGradient gradient = thor::createGradient(sf::Color(20, 10, 10)) (5) (sf::Color(50, 50, 50));


	thor::FadeAnimation fader(0.1f, 0.1f);
	thor::ColorAnimation colouriser(gradient);

	system->addAffector(thor::AnimationAffector::create(colouriser));
	system->addAffector( thor::AnimationAffector::create(fader) );
	system->addAffector( thor::TorqueAffector::create(0.f) );
	system->addAffector( thor::ForceAffector::create(sf::Vector2f(5.f, 0.f))  );



	
}


Clouds::~Clouds(void)
{
}

void Clouds::drawClouds(WindowManager* window)
{
	const sf::Time frameTime = frameClock.restart();
	system->update(frameTime);

	emitter->setParticlePosition(thor::Distributions::rect(monster->getPosition(), monster->getRectangle()));

	window->draw(*system);
}
